
package Testing;

import GameEngine.Client;
import GameEngine.GameConstants.Special;
import GameEngine.GameServer;
import GameEngine.InputMap;
import GameEngine.Level;
import LevelEditor.XmlIO;
import java.awt.Dimension;
import java.io.FileNotFoundException;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.dom4j.DocumentException;

/**
 * Runs a level without the server
 * @author mhfowler
 */
public class SystemTest {




       /* main method bitches */
    public static void main(String[] args)
    {

        ///// arguments
        int portnum = 1345;

        String xpath = "Levels/georgewashington.xml";

        // load level
        Level lev = null;
        try {
            lev = XmlIO.read(xpath);
        } catch (DocumentException ex) {
            Logger.getLogger(SystemTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(SystemTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }

        /* server */
        GameServer testServer = new GameServer(lev, portnum, (byte)0, null);

        //testServer.start();



       /* lets actually display it */
        JFrame mainFrame =  new JFrame("test");
        mainFrame.setVisible(true);
        mainFrame.setSize(new Dimension(1000,1500));
        mainFrame.setResizable(true);
        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


        /* client */
        Client c = new Client(mainFrame, "localhost", portnum, null);
        c.setType(Special.EXPLODER);
        c.initializeUserThread();
        JPanel panel = c.getPanel();
        mainFrame.add(panel);

        // to allow key binding
        InputMap input = new InputMap(panel, c);

    }



}
